#if !defined(ximera_gui_iguisystem_hpp)
#define ximera_gui_iguisystem_hpp

// -----------------------------------------------------------

#include <ximera/system/isystem.hpp>
#include <ximera/exception.hpp>

#include <ximera/gui/iwindow.hpp>

namespace ximera { namespace gui
{
    XIMERA_DECLARE_EXCEPTION(IncorrectWindowException, L"Window was not of specified type!");

    class XIMERA_API IGuiSystem : public system::ISystem
    {
    public:
        virtual void render() = 0;

        virtual void defaultFont(String const& name) = 0;
        virtual void mouseCursor(String const& imageName) = 0;

        virtual IWindow* createWindow(String const& type, String const& name) = 0;
        virtual IWindow* createWindow(String const& fileName) = 0;

        virtual void activeWindow(IWindow* window) = 0;
        virtual void loadScheme(String const& fileName) = 0;

        template <typename WindowType>
        WindowType* createWindow(String const& type, String const& name)
        {
            WindowType* result = dynamic_cast<WindowType*>(createWindow(type, name));
            if (!result)
                XIMERA_THROW(IncorrectWindowException, L"Window '" + type + L"' was not of specified type!");

            return result;
        }

        template <typename WindowType>
        WindowType* createWindow(String const& fileName)
        {
            WindowType* result = dynamic_cast<WindowType*>(createWindow(fileName));
            if (!result)
                XIMERA_THROW(IncorrectWindowException, L"Window '" + fileName + L"' was not of specified type!");

            return result;
        }
    };
}}

// -----------------------------------------------------------

#endif
